<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="Document.*,java.util.*,java.text.*" %>
<%@ include file="header.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="connecteur" scope="application" class="Document.DAO">
	<jsp:setProperty name="connecteur" property="driver" value="com.mysql.jdbc.Driver" />
	<jsp:setProperty name="connecteur" property="chaineConnexion" value="jdbc:mysql://localhost:3306/document" />
	<jsp:setProperty name="connecteur" property="login" value="root" />
	<jsp:setProperty name="connecteur" property="password" value="" />
</jsp:useBean>
<jsp:useBean id="user" class="Document.Utilisateur" scope="request">
<jsp:setProperty name="user" property="*"/>
</jsp:useBean>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Choix du type de document</title>
								
</head>
<body>
<%
	String typeDocument = request.getParameter("optionsDocument");
	session.setAttribute("typeDocument", typeDocument);
%>
<div class="container">
	<div class="row">
		<div class="span12">
		<%=typeDocument %>
			<div class="page-header">
				<h1>
					Choix du template pour le document <small>Le template</small>
				</h1>
			</div>
			<div class="row">
				<form action="creationTexte.jsp" method="post">
					<ul class="thumbnails">
						<% 	Template templates=new Template(); 
							
							if(typeDocument == null)
							{
								%>

								<jsp:forward page="choixDocument.jsp" />
								<%
								
							}
							else
							{
								ArrayList ArrayTemplate=templates.listeTemplate(connecteur, typeDocument);
								double nb_template = user.VerifAutorisation(Mail, connecteur, typeDocument);
								int test_nb =0;
								
								for (Iterator it=ArrayTemplate.iterator(); ((it.hasNext())&& (test_nb<nb_template));)
								{
									test_nb++;
									Template template=(Template) it.next();
							%>
							<li class="span3">
								<div class="thumbnail">
									<img data-src="holder.js/220x200" alt="">
									<div class="radio">
						  				<label>
						    				<input type="radio" name="optionsTemplate" id="optionsRadios" value="<%=template.getId() %>">
						    				<input type="hidden" name="Template" id="Template" value="<%=template.getLibelle() %>">
						    				<%=template.getLibelle() %>
						  				</label>
									</div>
								</div>
							</li>
							<% } }%>
					</ul>
					<div class="btn-group pull-right">
						<input type="submit" class="btn btn-success"></input>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
</body>
</html>